/*
 * TrainSchedule.java
 *
 * Created on October 5, 2007, 4:30 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package drb;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author Asger
 */
public class TrainSchedule {
    
    public int id;
    public long departure;
    public long arrival;
    public String from;
    public String to;
    public int ecoWagons;
    public int fcWagons;
    public String weekdays;
    public int ecoPrice;
    public int fcPrice;
    public boolean bedWagons;
    
    /** Creates a new instance of TrainSchedule */
    public TrainSchedule() {
    }
    
    public static TrainSchedule parse(ResultSet result, String prefix) throws SQLException {
        TrainSchedule schedule = new TrainSchedule();
        
        schedule.id = result.getInt(prefix + "schedule_id");
        schedule.departure = result.getLong(prefix + "departure");
        schedule.arrival = result.getLong(prefix + "arrival");
        schedule.from = result.getString(prefix + "from_name");
        schedule.to = result.getString(prefix + "to_name");
        schedule.ecoWagons = result.getInt(prefix + "eco_wagons");
        schedule.fcWagons = result.getInt(prefix + "fc_wagons");
        schedule.weekdays = result.getString(prefix + "week_days");
        schedule.ecoPrice = result.getInt(prefix + "eco_price");
        schedule.fcPrice = result.getInt(prefix + "fc_price");
        schedule.bedWagons = result.getString(prefix + "wagon_type").equals("B");
        
        return schedule;
    }
    
}








